package com.nt.train.controller;

import com.nt.train.config.properties.AliyunOssProperties;
import com.nt.train.service.OssService;
import com.nt.train.vo.ResultVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
/**
 * https://www.w3cschool.cn/article/66878551.html
 * https://blog.csdn.net/LINHONG_1994/article/details/103117838
 * 自定义条件处理
 * @author hlf
 * @version 1.0
 * @date 2022/8/4 10:47
 */
@RestController
@Slf4j
@RequestMapping("/aliyun")
public class AliyunController {

    @Autowired
    AliyunOssProperties aliyunOssProperties;

    //使用resource注解明确指定名称
    @Resource(name = "aliyunOssService")
    OssService aliyunOssService;

    @Autowired
    OssService minioOssService;

 //   @Autowired
//    @Qualifier("minioOssService")
//    OssService minioOssService;

//    //使用resource注解明确指定名称
//    @Qualifier("minioOssService")
//    @Resource
//    OssService minioOssService;


    @RequestMapping(value = "/read", method = RequestMethod.POST)
    public ResultVo read(){
        try {
            log.info("测试打印日志处理");
            return ResultVo.ok(aliyunOssProperties);
        } catch (Exception e) {
            return ResultVo.error(e.getMessage());
        }
    }

    @RequestMapping(value = "/read1", method = RequestMethod.POST)
    public ResultVo read1(){
        try {
            return ResultVo.ok(aliyunOssService.readProperties());
        } catch (Exception e) {
            return ResultVo.error(e.getMessage());
        }
    }

    @RequestMapping(value = "/read2", method = RequestMethod.POST)
    public ResultVo read2(){
        try {
            return ResultVo.ok(minioOssService.readProperties());
        } catch (Exception e) {
            return ResultVo.error(e.getMessage());
        }
    }
}
